//2009/08/24 11:25:14
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class TournamentsAmbiguityNumber
{
public:
    int scrutinizeTable(vector <string> table)
    {
		int ret = 0;
		int n = table.size();
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<n; j++)
			{
				if(i != j)
				for(int k=0; k<n; k++)
				{
					if(i!=k && j!=k)
					{
						if(table[i][j]=='1'&&table[j][k]=='1'&&table[k][i]=='1')
							ret++;
					}
				}
			}
		}
		return ret;
    }
};
